﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TVAFSWTXT
    {
        #region ==ZZ===========
        public static readonly DependencyProperty ZZProperty = DependencyProperty.Register("ZZ",
            typeof(string), typeof(TVAFSWTXT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZZChanged));
        public string ZZ
        {
            get
            {
                return (string)GetValue(ZZProperty);
            }
            set
            {
                SetValue(ZZProperty, value);
                OnExtInfoChg(value);
            }
        }
        private static void OnZZChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TVAFSWTXT;
            if (src != null)
            {
                src.ZZ = (string)e.NewValue;
            }
        }
        #endregion
        #region ==JS===========
        public static readonly DependencyProperty JSProperty = DependencyProperty.Register("JS",
            typeof(string), typeof(TVAFSWTXT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJSChanged));
        public string JS
        {
            get
            {
                return (string)GetValue(JSProperty);
            }
            set
            {
                SetValue(JSProperty, value);
                OnExtInfoChg(value);
            }
        }
        private static void OnJSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TVAFSWTXT;
            if (src != null)
            {
                src.JS = (string)e.NewValue;
            }
        }
        #endregion
        #region ==KH===========
        public static readonly DependencyProperty KHProperty = DependencyProperty.Register("KH",
            typeof(string), typeof(TVAFSWTXT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKHChanged));
        public string KH
        {
            get
            {
                return (string)GetValue(KHProperty);
            }
            set
            {
                SetValue(KHProperty, value);
                OnExtInfoChg(value);
            }
        }
        private static void OnKHChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TVAFSWTXT;
            if (src != null)
            {
                src.KH = (string)e.NewValue;
            }
        }
        #endregion
        #region ==YF===========
        public static readonly DependencyProperty YFProperty = DependencyProperty.Register("YF",
            typeof(string), typeof(TVAFSWTXT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnYFChanged));
        public string YF
        {
            get
            {
                return (string)GetValue(YFProperty);
            }
            set
            {
                SetValue(YFProperty, value);
                OnExtInfoChg(value);
            }
        }
        private static void OnYFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TVAFSWTXT;
            if (src != null)
            {
                src.YF = (string)e.NewValue;
            }
        }
        #endregion
        public virtual void OnExtInfoChg(string value)
        {
            INFO = ZZ + YF + JS + KH;
        }
        public TVAFSWTXT()
        {

            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVAART();
            this.DataContext = MV;
            InitializeComponent();

        }
        public override void LOADBYAUF()
        {
            if (ORDERNUM.Length == 0)
                return;
            KOLL = ORDERNUM.Substring(0, 5);
            ART = ORDERNUM.Substring(5, 24);
            if (!IsLoaded)
                return;
            base.LOADBYAUF();
        }
      
    }
}
